﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace XNAStuding
{
    /// <summary>
    /// this class is to start a timer or a stop watch which calculate the time in which the experiment work
    /// </summary>
    class Timer
    {
        public int msec = 0;
        public int min = 0;
        public int sec = 0;
        protected string ms = " ";
        protected string secstr = " ";
        protected string minstr = " ";
        public bool go;
        String time;

       
        public Timer()
        {
            this.time = "00:00:00";
            this.go = false;
           
        }
        /// <summary>
        /// this is a method to stop the timer
        /// </summary>
        /// <returns>this method return the time in a string</returns>
        public string stop()
        {
            msec = 0;
            min = 0;
            sec = 0;

            ms = Convert.ToString(msec);
            secstr = Convert.ToString(sec);
            minstr = Convert.ToString(min);
            time = minstr + ": " + secstr + ": " + ms;
            return time;
            
        }
        /// <summary>
        /// this method used to start the timer
        /// </summary>
        /// <returns>this method return the time in a string</returns>
        public string increase()
        {
            if (go)
            {
                msec = msec + 1;
                if (msec < 1000)
                    msec++;
                if (msec == 1000)
                {
                    sec++;
                    msec = 0;
                }
                if (sec >= 60)
                {
                    min++;
                    sec = 0;
                    msec = 0;
                }

               
            }
            ms = Convert.ToString(msec);
            secstr = Convert.ToString(sec);
            minstr = Convert.ToString(min);
            time=minstr + ": " + secstr + ": " + ms;
            return time;
        }

        public string drawTimer()
        {
            return time;
        }
    }
}
